<!doctype html>
<html>
<head>
	<meta charset="UTF-8">
	<title></title>
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<link href="../css/mui.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="../css/setting.css" />
</head>

<body class="gray">
	<div class="mui-content">
	    <form class="mui-input-group" style="margin-top: 10px;">
	        <div class="mui-input-row">
	            <input type="text" class="mui-input-clear" id="phone" disabled="disabled" placeholder="" />
	        </div>
	        <div class="mui-input-row getcode">
	            <input type="text" id="codes" placeholder="请输入验证码" />
	            <a class="mui-btn bexta-btn bexta-btn-red codeBtn">获取验证码</a>
	        </div>
	    </form>
	    <div class="mui-content-padded" style="margin-top: 25px;">
			<button type="button" class="mui-btn bexta-btn bexta-btn-red mui-btn-block enter">下一步</button>
	    </div>
	    
	    <p class="reTips">遇到无法解决的问题？联系客服</p>
	    
	    
	</div>
<script src="../js/mui.js"></script>
<script src="../js/bexta.js"></script>
<script type="text/javascript">
	mui.init()
	mui.plusReady(function () {
		var call = '';
	   var user = bexta.getStorage(USER);
	   var phone = document.querySelector('#phone');
	   phone.value = user.mobile;
	   document.querySelector('.codeBtn').addEventListener('tap', function(){
	   		var f = mui('.codeBtn').button('loading');
			bexta.ajax(''+api.send_msg, function(res){
				if( res.isError == 0 ){
					mui.toast(res.msg);
					bexta.countDown(90, function(m){
						if( m <=1  ){
							f.reset();
						}else{
							f.setText(m + '秒');
						}
					});
				}else{
					mui.toast(res.msg);
					f.reset();
				}
			},{data:{mobile:phone.value, type:7, uid:user.uid}},function(){
				f.reset();
			});
	   });
	   document.querySelector('.enter').addEventListener('tap', function(){
	   		var code = document.querySelector('#codes').value;
	   		if( code == '' ){
	   			mui.toast("请输入验证码");
	   			return;
	   		}
	   		bexta.ajax(api.change_mobile, function(result){
	   			 bexta.openWithTitle({
		   		 	id:'rephone2',
		   		 	url:'rephone2.html',
		   		 	extras:{
		   		 		codes:code,
		   		 		calphone:call
		   		 	}
		   		 },{
		   		 	title:{
		   		 		text:"新手机"
		   		 	}
		   		 });
	   		}, {data:{uid:user.uid, type:1, oldcode:code, oldmobile:user.mobile}})
	   		
	   });
	   
	   bexta.ajax(api.web_infor, function(res){
	   		call = res.web_service_phone;
	   		initCallPhone(res);
	   },{})
	});
function initCallPhone(call){
	document.querySelector('.reTips').addEventListener('tap', function(){
		plus.device.dial(call.web_service_phone, true);
	});
	
}
</script>
</body>
</html>